# Contributor: Mark Pashmfouroush <mark@markpash.me>
# Maintainer: Mark Pashmfouroush <mark@markpash.me>
pkgname=corerad
pkgver=1.2.1
pkgrel=0
pkgdesc="Extensible and observable IPv6 Neighbor Discovery Protocol router advertisement daemon"
url="https://corerad.net/"
license="Apache-2.0"
arch="all"
options="net" # Requires net for getting go module dependencies
makedepends="go libcap"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/mdlayher/corerad/archive/v$pkgver.tar.gz
	corerad.initd
	"

# access denied for ipv6 autoconfiguration
[ "$CARCH" = "s390x" ] && options="$options !check"

build() {
	make VERSION="$pkgver"

	# create a minimal configuration file
	./cmd/corerad/corerad -init
}

check() {
	go test ./...
}

package() {
	install -Dm755 cmd/corerad/corerad "$pkgdir"/usr/sbin/corerad
	setcap cap_net_admin,cap_net_raw+eip "$pkgdir"/usr/sbin/corerad

	install -Dm755 "$srcdir"/corerad.initd "$pkgdir"/etc/init.d/corerad
	install -Dm644 corerad.toml "$pkgdir"/etc/corerad/config.toml
}
sha512sums="
48a5f33cb4dccf5fe650232df46c8d35e94833b569468775657cead34040bfb322b7f556a156c6827a3540ced00f1e5443c07f68651ea13ef5434731dcf3320f  corerad-1.2.1.tar.gz
96c40309aa6e81db5e5d136ee2ca9b1c24471acd1b20ff773020d3106dcc82e0fcb4b52112cbcb2b16c45211073b1d19bc0381ef7d93bd1c3cf53745633a22b4  corerad.initd
"
